<?php $this->load->view('header');?>

    <div class="wrap-intro">
        <div class="container">
            <div class="row">
                <div class="app-form app-form-login col-lg-12 col-xs-12 col-md-12 col-sm-12">

                	<div class="col-md-5 col-sm-5">
                		<img class="img-responsive" src="<?php echo base_url()?>/app/css/images/bg_login.png">
                	</div>
                    <?php
                    //Show Flash Message
                    if ($msg = $this->session->flashdata('flash_message')) {
                        ?>
                        <div style="color:red">
                            <?php
                            echo $msg['msg'];
                            ?>
                        </div>
                    <?php
                    }
                    ?>
                	<div class="col-md-7 col-sm-7">
                    	<form id="frm-login" method="POST">
                    		<div class="col-md-12">
                    			<h2><?php echo $this->lang->line('Log into your account');?></h2>
                    		</div>

                    		<div class="form-group">
		                        <div class="col-md-6 col-sm-6">
		                            <input type="text" name="username" class="form-control" id="username" placeholder='<?php echo $this->lang->line('placeholder_login_user')?>'>
		                        </div>
		                        <div class="col-md-6 col-sm-6">
		                            <input type="password" name="password" class="form-control" id="password" placeholder='<?php echo $this->lang->line('placeholder_login_password')?>'>
		                        </div>
	                        </div>
	                        <div class="col-md-12 remember">
	                            <label>
	                                <input type="checkbox" onclick="confirm('Chức năng đang hoàn thiện')" name="remember"> <?php echo $this->lang->line('Remember')?>
	                            </label>
	                        </div>
	                        <div class="form-group">
		                        <div class="col-md-6">
		                            <button type="submit" name="usersLogin" value="usersLogin" class="btn btn-create col-sm-12 col-md-12 col-xs-12 btn-lg">
			                            <i class="icon_edit"></i>
			                            <?php echo $this->lang->line('Login')?>
		                            </button>
	                            </div>
	                           	<div class="col-md-6">
                                    <a style="color:#fff;font-size:24px;margin-top:0px;"  class="btn-login-facebook-api btn-login-facebook btn btn-facebook col-sm-12 col-md-12 col-xs-12 btn-lg btn-block">
                                        <i class="icon_facebook"></i>
                                        <?php echo $this->lang->line('Login Facebook')?>
                                    </a>
									<a title="google" href="javascript:void(0);" onclick="javascript:initiateSignIn();">Đăng nhập Google</a>
	                           	</div>
	                        </div>
	                        
                            <p class="col-sm-12 app-link-forget">
                            <a href="<?php echo site_url('users/forgotPassword'); ?>"><?php echo $this->lang->line("Forget password?")?></a></p> 
                        
                            <p class="col-sm-12"><?php echo $this->lang->line("Don't have account?")?> <span><a style="color:#22b88d" href="<?php echo site_url('buyer/signup'); ?>"><?php echo $this->lang->line("Register_now")?></a></span>
                            </p>
	                       
                    	</form>
                	</div>
                </div>
                <!-- app-form-login -->
            </div>

        </div>
        <!-- /.container -->
    </div> <!-- wrap intro -->

    <script language="javascript" type="text/javascript">
        $(document).ready(function () {
            $("#frm-login").validate({
            	errorElement: "span", // contain the error msg in a span tag
                errorClass: 'help-block',
                errorPlacement: function (error, element) { // render error placement for each input type
                    if (element.attr("type") == "radio" || element.attr("type") == "checkbox") { // for chosen elements, need to insert the error after the chosen container
                        error.insertAfter($(element).closest('.form-group').children('div').children().last());
                    } else if (element.attr("name") == "dd" || element.attr("name") == "mm" || element.attr("name") == "yyyy") {
                        error.insertAfter($(element).closest('.form-group').children('div'));
                    } else {
                        error.insertAfter(element);
                        // for other inputs, just perform default behavior
                    }
                },
                highlight: function (element) {
                    $(element).closest('.help-block').removeClass('valid');
                    // display OK icon
                    $(element).closest('.form-group').removeClass('has-success').addClass('has-error').find('.symbol').removeClass('ok').addClass('required');
                    // add the Bootstrap error class to the control group
                },
                unhighlight: function (element) { // revert the change done by hightlight
                    $(element).closest('.form-group').removeClass('has-error');
                    // set error class to the control group
                },
                success: function (label, element) {
                    label.addClass('help-block valid');
                    // mark the current input as valid and display OK icon
                    $(element).closest('.form-group').removeClass('has-error').addClass('has-success').find('.symbol').removeClass('required').addClass('ok');
                },
                rules: {
                    "username": {
                        required: true,
                        minlength: 5
                    },
                    "password": {
                        required: true,
                        minlength: 5
                    }
                },
                messages: {
                    "username": {
                        required: "<?php echo $this->lang->line('Username')." ".$this->lang->line('required') ?>",
                        minlength: "<?php echo $this->lang->line('Username')." ".$this->lang->line('min_length'); ?>"
                    },
                    "password": {
                        required: "<?php echo $this->lang->line('Password')." ".$this->lang->line('required') ?>",
                        minlength: "<?php echo $this->lang->line('Password')." ".$this->lang->line('min_length'); ?>"
                    }
                }
            });

        });
    </script>
<?php $this->load->view('footer'); ?>